/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.unicamp.ic.sgct.server.dominio.entidades;

import br.unicamp.ic.sgct.client.dominio.to.PerfilTO;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.TableGenerator;

/**
 *
 * @author arthur
 */
@Entity
@Table(name = "T_PERFIL")
@TableGenerator(name = "PERFIL_GEN", allocationSize = 1, initialValue = 1, table = "T_ID",
pkColumnName = "key", valueColumnName = "valor", pkColumnValue = "ID_PERFIL")
public class Perfil implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @Column(name = "id_perfil")
    @GeneratedValue(strategy = GenerationType.TABLE, generator = "PERFIL_GEN")
    private int id;
    private String nome;
    private String descricao;

    public Perfil() {
        super();
    }
    public Perfil(PerfilTO to) {
        this.nome = to.getNome();
        this.descricao = to.getDescricao();
        this.id = to.getId();
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (int) id;
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Perfil)) {
            return false;
        }
        Perfil other = (Perfil) object;
        if (this.id != other.id) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "br.unicamp.ic.sgct.server.dominio.entidades.Perfil[id=" + id + "]";
    }

    /**
     * @return the nome
     */
    public String getNome() {
        return nome;
    }

    /**
     * @param nome the nome to set
     */
    public void setNome(String nome) {
        this.nome = nome;
    }

    /**
     * @return the descricao
     */
    public String getDescricao() {
        return descricao;
    }

    /**
     * @param descricao the descricao to set
     */
    public void setDescricao(String descricao) {
        this.descricao = descricao;
    }

    public PerfilTO getTo() {
        PerfilTO to = new PerfilTO();
        to.setNome(nome);
        to.setId(id);
        to.setDescricao(descricao);
        return to;
    }
}
